home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / gfx / show / jpegAGAsrc21.lha / jpegAGAsrc / jpegAGA / pattern.c < prev    next >
C/C++ Source or Header  |  1995-01-14  |  1KB  |  64 lines

  1. /* Fill the buffer with file names */
  2.  
  3. #include <dos/dosasl.h>
  4.  
  5. #ifndef __GNUC__
  6. #include <pragmas/dos_pragmas.h>
  7. #include <clib/dos_protos.h>
  8. #else
  9. #include <inline/dos.h>
  10. #endif
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14.  
  15. #define MAXFILES 500
  16.  
  17. extern char *PicArray[];
  18. extern int NumPictures;
  19.  
  20.  
  21. void FillNameBuffer(char *pattern)
  22. {
  23.  int i;
  24.  LONG error;
  25.  struct AnchorPath *MyAnchorPath;
  26.  
  27.  MyAnchorPath = calloc(sizeof(struct AnchorPath)+256, 1);
  28.  
  29.  if(MyAnchorPath == NULL)
  30.  {
  31.    printf("Out of memory!\n");
  32.    exit(10);
  33.  }
  34.  
  35.  MyAnchorPath->ap_Strlen = 254;
  36.  
  37.  error = MatchFirst(pattern, MyAnchorPath);
  38.  if(error) return;
  39.  
  40.  while(!error)
  41.  {
  42.    PicArray[NumPictures] = malloc(strlen((char *)&MyAnchorPath->ap_Buf)+1);
  43.    if(!PicArray[NumPictures])
  44.    {
  45.      printf("Out of memory!\n");
  46.      MatchEnd(MyAnchorPath);
  47.      exit(10);
  48.    }
  49.    strcpy(PicArray[NumPictures], MyAnchorPath->ap_Buf);
  50.    /* puts(PicArray[NumPictures]); */
  51.    NumPictures++;
  52.    if(NumPictures == MAXFILES)
  53.    {
  54.      printf("Too many files!\n");
  55.      MatchEnd(MyAnchorPath);
  56.      return;
  57.    }
  58.    error = MatchNext(MyAnchorPath);
  59.  }
  60.  
  61.  MatchEnd(MyAnchorPath);
  62.  if(MyAnchorPath) free(MyAnchorPath);
  63. }
  64.